home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / thesource6.dms / thesource6.adf / Source / Compression / hcompress.lha / hcompress / unix / hdecompress.csh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-04-21  |  1.9 KB  |  76 lines

  1. #! /bin/csh
  2. # Shell file to do H-transform image de-compression for a list of files.
  3. #
  4. # If .H is not explicitly specified on end of compressed file names,
  5. # it is added.
  6. #
  7. # Files are replaced by uncompressed file with .H removed from name.
  8. #
  9. set noclobber
  10. set shellfile=$0
  11. set cdir=`dirname $shellfile`
  12. set prgnam=${shellfile:t}
  13. #
  14. if ($#argv == 0) then
  15.     echo "Usage: ${prgnam} [options] files... [options] files..."
  16.     echo "  where options are:"
  17.     echo "     -s to enable smoothing"
  18.     echo "     -u to disable smoothing (default)"
  19.     echo "     -k to keep the compressed file (default)"
  20.     echo "     -r to remove the compressed file"
  21.     echo "     -o raw | net | fits | hhh to specify the output image format"
  22.     echo "        The default output format is raw (= hhh) unless the original"
  23.     echo "        image was FITS format, in which case the default is fits"
  24.     echo "        format."
  25.     exit
  26. endif
  27. set remove=0
  28. set smooth
  29. set format
  30. set nextformat=0
  31. foreach file ($*)
  32.     if ($nextformat) then
  33.         set format=$file
  34.         set nextformat=0
  35.     else if ("$file" == "-o") then
  36.         set nextformat=1
  37.     else if ("$file" == "-r") then
  38.         set remove=1
  39.     else if ("$file" == "-k") then
  40.         set remove=0
  41.     else if ("$file" == "-s") then
  42.         set smooth="-s"
  43.     else if ("$file" == "-u") then
  44.         set smooth
  45.     else
  46.         if (${file:e} == 'H') then
  47.             set infile=$file
  48.             set outfile=${file:r}
  49.         else
  50.             set infile=$file.H
  51.             set outfile=$file
  52.         endif
  53.         if (-e $outfile) then
  54.             echo "${prgnam}: ${outfile} already exists"
  55.         else if (! -e $infile) then
  56.             echo "${prgnam}: ${infile}: No such file"
  57.         else
  58.             echo -n "$outfile "
  59.             if ($format == "") then
  60.                 $cdir/hdecomp -v $smooth < $infile > $outfile
  61.             else
  62.                 $cdir/hdecomp -v $smooth -o $format < $infile > $outfile
  63.             endif
  64.             if ($status == 0) then
  65.                 if ($remove) then
  66.                     # delete compressed file
  67.                     /bin/rm $infile
  68.                 endif
  69.             else
  70.                 echo "${prgnam}: error, $infile not decompressed
  71.                 /bin/rm $outfile
  72.             endif
  73.         endif
  74.     endif
  75. end
  76.